<?php
// ========================== 文件说明 ==========================//
// 本文件说明：自动分析替换模板里的URL
// ==============================================================//

if(!defined('IN_ROOT')) {
	exit('Access Denied');
}

//转换分类的连接
function rewrite_category($head, $cid, $uid, $page = 1, $class = '') {
	global $options;
	!$page && $page = 1;
	return '<a href="'.$head.'category-'.$cid.'-'.$uid.'-'.$page.'.'.$options['rewrite_ext'].'"'.($class ? ' class="'.$class.'"' : '').'>';
}

//转换标签的连接
function rewrite_tags($head, $item, $uid, $page = 1, $class = '') {
	global $options;
	!$page && $page = 1;
	return '<a href="'.$head.$item.'-'.$uid.'-'.$page.'.'.$options['rewrite_ext'].'"'.($class ? ' class="'.$class.'"' : '').'>';
}

//转换首页最新留言
function rewrite_newcm($head, $id, $uid, $cmid, $class = '') {
	global $options;
	!$page && $page = 1;
	return '<a href="'.$head.'comments-'.$id.'-'.$uid.'-'.$cmid.'.'.$options['rewrite_ext'].'"'.($class ? ' class="'.$class.'"' : '').'>';
}

//转换日历的链接
function rewrite_date($head, $date, $day, $uid, $page = 1, $class = '') {
	global $options;
	!$page && $page = 1;
	return '<a href="'.$head.$date.$day.'-'.$uid.'-'.$page.'.'.$options['rewrite_ext'].'"'.($class ? ' class="'.$class.'"' : '').'>';
}

//转换归档的连接
function rewrite_archives($head, $date, $uid, $page = 1, $class = '') {
	global $options;
	!$page && $page = 1;
	return '<a href="'.$head.'archives-'.$date.'-'.$uid.'-'.$page.'.'.$options['rewrite_ext'].'"'.($class ? ' class="'.$class.'"' : '').'>';
}

//转换文章的连接
function rewrite_show($head, $id, $uid, $page = 1, $extra = '', $class = '') {
	global $options;
	!$page && $page = 1;
	return '<a href="'.$head.'articles-'.$id.'-'.$uid.'-'.$page.'.'.$options['rewrite_ext'].($extra ? '#'.$extra : '').'"'.($class ? ' class="'.$class.'"' : '').'>';
}

//转换其他页面的连接
function rewrite_page($head, $action, $page = 1, $class = '') {
	global $options;
	!$page && $page = 1;
	if (in_array($action,array('search','archives','reg','login','links'))) {
		$pagelink = '';
	} else {
		$pagelink = '-'.$uid.'-'.$page;
	}
	return '<a href="'.$head.$action.$pagelink.'.'.$options['rewrite_ext'].'"'.($class ? ' class="'.$class.'"' : '').'>';
}

?>